﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using LM.Negocio.Objetos;

namespace LM.Repositorios.Maps
{
    public class TabelaPrecoMap : EntityTypeConfiguration<TabelaPreco>
    {
        public TabelaPrecoMap()
        {
            this.HasKey(c => c.Id);
            this.Property(c => c.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).HasColumnName("Id");

            this.Property(c => c.Codigo).HasColumnName("Codigo").IsRequired();
            this.Property(c => c.Nome).HasColumnName("Nome").IsRequired();
            this.Property(c => c.DataInicio).HasColumnName("DataInicio").IsRequired();
            this.Property(c => c.DataFim).HasColumnName("DataFim");

            HasMany(p => p.ItemTabela)
                .WithRequired(s => s.TabelaPreco)
                .HasForeignKey(s => s.IdTabelaPreco).WillCascadeOnDelete(true);

            this.ToTable("TABELAPRECO");
        }
    }
}
